package com.example.larouzey.broadnotifytest_201ljy;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    private EditText et;
    private Button bts,btnf;
    private String UNIQUE_STRING="com.example.larouzey.broadnotifytest_201ljy";

    private View.OnClickListener listener=new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()){
                case R.id.button:
                    Intent intent = new Intent(UNIQUE_STRING);
                    intent.putExtra("para1",et.getText().toString());
                    sendBroadcast(intent);
                    break;
                case R.id.button2:
                    MyReceiver.manager.cancel(MyReceiver.notifyID);
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();

    }


    private void init() {
        et=(EditText)findViewById(R.id.editText);
        bts=(Button) findViewById(R.id.button);
        btnf=(Button)findViewById(R.id.button2);
        bts.setOnClickListener(listener);
        btnf.setOnClickListener(listener);
    }

}
